The dynamic menu system in the GrowERP Admin app is a flexible and modular architecture that allows for easy configuration of the application's navigation structure. Here's a comprehensive explanation of how it works and its relationship with the template directory and configuration files. It is used in all the apps to enable easy layout of the menu
The menu system is primarily defined in flutter/packages/admin/lib/menu_options.dart, which contains a list of MenuOption objects that define the main navigation structure of the application. Each MenuOption represents a top-level menu item and can contain:
image and selectedImage: Icons for unselected and selected statestitle: The display name of the menu optionroute: The navigation route for this menu optionuserGroups: Access control list defining which user groups can see this optionchild: A direct widget to display when this menu option is selected (for simple pages)tabItems: A list of TabItem objects for multi-tab interfacesTabItem within a MenuOption defines a tab and contains:
form: The widget to display in this tablabel: The tab's display nameicon: The icon to show in the tab bar or bottom navigationThe template directory (flutter/packages/growerp_core/lib/src/templates/) contains the core components that render the menu system:
display_menu_option.dart):
myNavigationRail: Renders the side navigation rail for tablet/desktop viewsmyDrawer: Renders the drawer menu for mobile viewsmenuOptions listtemplates.dartThe menu system rendering follows this flow:
main.dart, the app initializes with TopApp and passes the menuOptions listTopApp sets up the application shell and passes the menu options to HomeFormHomeForm uses DisplayMenuOption to render the current menu selectionmyNavigationRail (desktop/tablet) or myDrawer (phone) is usedrouter.dart) handles navigation between menu optionsacct_menu_options.dartHomeForm with this specialized menuThe menu system is designed for extensibility:
menuOptions listThis architecture allows the GrowERP Admin app to maintain a consistent UI while supporting a wide range of functionality through its modular, configuration-driven menu system.